import Vue from 'vue'
// element
import ElementUI from 'element-ui'
// 自定义指令
import permission from './directive'

// 权限路由守卫
import './permission' // permission control

// px 转化 rem
import remConfig from '@/utils/publicUtils/remConfig'// rem转换的js文件
remConfig()

/* css */
import '@/assets/styles/index.scss' // global css
import '@/assets/icons' // icon

// app
import App from './App'

// vuex 中心库
import store from './store'

// 路由
import router from './router'

/* 第三方 插件工具  */
// 二维码
import qrcode from 'qrcode'
Vue.prototype.$qrcode = qrcode
// 图表
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts

/* 自定义工具 */
// 加密解密
import crypto from '@/utils/publicUtils/crypto'
Vue.prototype.$crypto = crypto

/* 第三方 插件组件 */
// 超大附件上传
import uploader from 'vue-simple-uploader'
Vue.use(uploader)

/* 自定义组件 */
// 分页
import Pagination from '@/components/publicComponents/Pagination'
Vue.component('Pagination', Pagination)

// 上传文件
import UploadFile from '@/components/publicComponents/uploadNew/indexFile'
Vue.component('UploadFile', UploadFile)

// 富文本编辑器
import wangEitor from '@/components/publicComponents/wangEitor/index.vue'
Vue.component('wangEitor', wangEitor)

/* api */
import { getConfigKey, getDicts } from '@/api/commonApi'
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey

/* 方法 */
import {
  parseTime,
  getTimeDate,
  resetForm,
  validateFormField,
  selectDictLabel,
  selectDictLabels,
  arrayToString,
  handleTree,
  download,
  praseStrEmpty,
  sentencedEmpty,
  toChineseNum,
  toChinesNum,
  focusNumBerFun,
  blurNumBerFun,
  numberInput,
  numberInputGeo,
  numberFormat,
  msgAlt,
  pageIndex,
  mathRound,
  decimalRound,
  findNodeById,
  timeChangeFun,
  rrayUnique,
  isChina,
  isFileChinaNameBack,
  percent2percent25,
  tabsPermission,
  btnPermission,
  isImage
} from '@/utils/commonUtils/HLUtils'

Vue.prototype.parseTime = parseTime
Vue.prototype.getTimeDate = getTimeDate
Vue.prototype.resetForm = resetForm
Vue.prototype.validateFormField = validateFormField
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.arrayToString = arrayToString
Vue.prototype.handleTree = handleTree
Vue.prototype.download = download
Vue.prototype.praseStrEmpty = praseStrEmpty
Vue.prototype.sentencedEmpty = sentencedEmpty
Vue.prototype.toChineseNum = toChineseNum
Vue.prototype.toChinesNum = toChinesNum
Vue.prototype.focusNumBerFun = focusNumBerFun
Vue.prototype.blurNumBerFun = blurNumBerFun
Vue.prototype.numberInput = numberInput
Vue.prototype.numberInputGeo = numberInputGeo
Vue.prototype.numberFormat = numberFormat
Vue.prototype.msgAlt = msgAlt
Vue.prototype.pageIndex = pageIndex
Vue.prototype.mathRound = mathRound
Vue.prototype.decimalRound = decimalRound
Vue.prototype.findNodeById = findNodeById
Vue.prototype.timeChangeFun = timeChangeFun
Vue.prototype.rrayUnique = rrayUnique
Vue.prototype.isChina = isChina
Vue.prototype.isFileChinaNameBack = isFileChinaNameBack
Vue.prototype.percent2percent25 = percent2percent25
Vue.prototype.tabsPermission = tabsPermission
Vue.prototype.btnPermission = btnPermission
Vue.prototype.isImage = isImage

// 验证表单 正则验证公共调取函数
import { regularFun, numberArrayFun, numberWarFun, timeValidateFun, wangEitorFun } from '@/utils/commonUtils/validate.js'
Vue.prototype.regularFun = regularFun
Vue.prototype.numberArrayFun = numberArrayFun
Vue.prototype.numberWarFun = numberWarFun
Vue.prototype.timeValidateFun = timeValidateFun
Vue.prototype.wangEitorFun = wangEitorFun

// 计算页面高度
import resizeViewConfig from '@/utils/commonUtils/resizeViewConfig'// 全局更改大小
Vue.prototype.resizeViewConfig = resizeViewConfig

// 全局设置 点击遮罩不消失dialog
ElementUI.Dialog.props.closeOnClickModal.default = false
window.addEventListener('resize', function() {
  remConfig()
})
Vue.use(ElementUI, { size: 'small' })
Vue.use(permission)

Vue.config.productionTip = false
Vue.config.productionGzip = true // 是否开启gizp压缩
Vue.config.productionGzipExtensions = ['js', 'css']
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
